import logging
import os
import sys
import pytest
from utils.send_feishu_msg import send_feishu_msg

if __name__=="__main__":
    print(sys.argv)
    if len(sys.argv) == 2:
        if sys.argv[1] == "test":
            # 根据实际情况进行修改
            # os.environ["URL"] = "http://192.168.10.142/api/cloud-api"
            # os.environ["DB"] = str({
            #     "host": "192.168.10.142",
            #     "port": 3306,
            #     "user": "root",
            #     "password": "123456",
            #     "db": "xingyun"
            # })
            os.environ["ENV"] = "test"
            pass
        elif sys.argv[1] == "prod":
            os.environ["URL"] = "http://192.168.10.142/api/cloud-api"
            os.environ["DB"] = str({
                "host": "192.168.10.142",
                "port": 3306,
                "user": "root",
                "password": "123456",
                "db": "xingyun"
            })
            os.environ["ENV"] = "prod"
            print(os.environ)
        else:
            pass
    else:
        logging.info("请传入正确的执行命令：python run.py test 或者 python run.py prod")

    pytest.main(["-vs", "./testcases/test_runner.py", "--alluredir", "./report/json_report", "--clean-alluredir"])
    os.system("allure generate ./report/json_report -o ./report/html_report --clean")
    send_feishu_msg()
